package com.woniu.config;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author hq
 * @Date 2025/6/18$ 14:55$
 * @Description TODO
 * @Params $
 * @Return $
 **/
@Component
public class ContainerCache {

    // 容器ID -> 开始时间
    private final Map<String, Long> containerStartTimeMap = new ConcurrentHashMap<>();

    public void addContainer(String containerId) {
        containerStartTimeMap.put(containerId, System.currentTimeMillis());
    }

    public void removeContainer(String containerId) {
        containerStartTimeMap.remove(containerId);
    }

    public Map<String, Long> getAllContainers() {
        return new HashMap<>(containerStartTimeMap);
    }
}
